package com.sf.fy.uav.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sf.fy.uav.entity.CouponActivityDetail;
import com.sf.fy.uav.mapper.CouponActivityDetailMapper;
import com.sf.fy.uav.service.ICouponActivityDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 订单商品关联表 服务实现类
 * </p>
 *
 * @author LTQ
 * @since 2024-08-27
 */
@Service
public class CouponActivityDetailServiceImpl extends ServiceImpl<CouponActivityDetailMapper, CouponActivityDetail> implements ICouponActivityDetailService {
    @Autowired
    private CouponActivityDetailMapper couponActivityDetailMapper;

    @Override
    public List<CouponActivityDetail> getDetails(String couponActivityId) {
        QueryWrapper<CouponActivityDetail> couponActivityRecordQueryWrapper = new QueryWrapper<>();
        couponActivityRecordQueryWrapper.eq("coupon_activity_id", couponActivityId);
        return couponActivityDetailMapper.selectList(couponActivityRecordQueryWrapper);
    }

    @Override
    public List<CouponActivityDetail> getDetailsByCouponActivityIds(List<String> couponActivityIds) {
        QueryWrapper<CouponActivityDetail> couponActivityRecordQueryWrapper = new QueryWrapper<>();
        couponActivityRecordQueryWrapper.in("coupon_activity_id", couponActivityIds);
        return couponActivityDetailMapper.selectList(couponActivityRecordQueryWrapper);
    }

    @Override
    public List<CouponActivityDetail> getDetailsByCouponIds(List<String> couponIds) {
        QueryWrapper<CouponActivityDetail> couponActivityRecordQueryWrapper = new QueryWrapper<>();
        couponActivityRecordQueryWrapper.in("coupon_id", couponIds);
        return couponActivityDetailMapper.selectList(couponActivityRecordQueryWrapper);
    }

    @Override
    public List<CouponActivityDetail> selByCouponIdAndStock(String couponId, Integer stock) {
        QueryWrapper<CouponActivityDetail> couponActivityDetailQueryWrapper = new QueryWrapper<>();
        couponActivityDetailQueryWrapper.eq("coupon_id", couponId);
        couponActivityDetailQueryWrapper.gt("cnt", stock);
        return couponActivityDetailMapper.selectList(couponActivityDetailQueryWrapper);
    }

}
